package com.shuaigef.springbootinit.oss.fatory;

import com.shuaigef.springbootinit.oss.strategy.FileStrategy;
import com.shuaigef.springbootinit.oss.strategy.impl.MinioFileStrategy;
import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration

@RequiredArgsConstructor
public class FileStrategyFactory {

    @Value("${storage.type}")
    private String strategyType;

    @Bean
    public FileStrategy getFileStrategy() {
        if ("minio".equals(strategyType)) {
            return new MinioFileStrategy();
        }
//        else if ("aliyun".equals(strategyType)) {
//            return new AliyunOSSFileStrategy();
//        }
        throw new IllegalArgumentException("不可用的存储类型");
    }
}

